<template>
  <div class="user">
    <el-table v-if="som"
        :data="this.userList.filter(data => !search || data.mobileNo.toLowerCase().includes(search.toLowerCase())).slice((currentPage-1)*pagesize,currentPage*pagesize)"
        style="width: 100%">
        <el-table-column prop="userName" label="注册姓名"></el-table-column>
        <el-table-column prop="nickName" label="微信昵称"></el-table-column>
        <el-table-column prop="mobileNo" label="联系电话"></el-table-column>
        <el-table-column prop="registerTime" label="注册时间"></el-table-column>
        <el-table-column align="center" prop="accountType" label="注册版本">
            <template slot-scope="scope">
                <el-tag 
                    :type="scope.row.accountType == 1 ? 'success' : 'primary'"
                    disable-transitions>{{scope.row.accountType == 1 ? '家庭版' : '企业版' }}</el-tag>
            </template>
        </el-table-column>
        <el-table-column prop="isManage" label="用户状态">
          <template slot="header" slot-scope="scope">
          <el-input
            v-model="search"
            size="mini"
            :key="scope.row"
            placeholder="输入手机号搜索"/>
          </template>
            <template slot-scope="scope">
                <el-tag 
                    :type="scope.row.isManage == 0 ? 'success' : ( scope.row.isManage == 1 ?'primary':'info')"
                    disable-transitions>{{scope.row.isManage == 0 ? '普通用户' : (scope.row.isManage == 1 ?'管家会员' :'会员过期') }}</el-tag>
            </template>
        </el-table-column>
        <!-- <el-table-column align="center" label="操作">
          <template slot="header" slot-scope="scope">
          <el-input
            v-model="search"
            size="mini"
            :key="scope.row"
            placeholder="输入手机号搜索"/>
          </template>
          <template slot-scope="scope">
              <el-button
              size="mini"
              type="warning"
              @click="handleFind(scope.$index, scope.row)">查看</el-button>
          </template>
        </el-table-column> -->
    </el-table>
    <el-pagination v-if="som"
      align="center"
      class="fenye"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      :page-size="pagesize"
      layout="total, prev, pager, next"
      :total="this.userList.length">
    </el-pagination>
    <router-view />
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
  created(){
    this.getUserList();
  },
  data() {
    return {
      som : true,
      search: '',
      pagesize:15,
      currentPage: 1
    }
  },
  computed:{
    ...mapState({
        userList:state => state.userModule.userList
        // goodOrderList: state => state.jifenModule.goodOrderList,
        // jifenInfo: state => state.jifenModule.jifenInfo
    }),
  },
  methods:{
    ...mapActions({
      // getGoodOrderList:'jifenModule/getGoodOrderList'
      getUserList:'userModule/getUserList'
    }),
    handleFind(index, row){
      // this.$router.push({path:'/jifen/find',query:{orderNumber:row.orderNumber}})
    },
    orderStata(value, row) {
      // return this.orderStatusInfo(row) == value;
    },
    handleCurrentChange(currentPage) {
      // this.currentPage = currentPage;
    }
  },      
  // 路由守卫判断 是否进入详情页,隐藏添加客服按钮
  beforeRouteUpdate(to, from, next){
      if((to.path !== '/user')&&(from.path === '/user')){
          this.som = false;
      }else{
          this.som = true;
      }
      next();
  },
  //不是详情页刷新页面，隐藏添加客服按钮
  mounted(){
      if(this.$route.path !== '/user'){
          this.som = false;
      }
  }
}
</script>

<style lang="scss" scoped>
.user{
  width: 100%;
  background: #fff;
  padding: 10px;
  box-sizing: border-box;
}

</style>

